<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>验证二叉搜索树</title>
</head>
<body>
  <script>
    function fn(root) {
      let res = [];
      var dfs = function (root) {
        if (root === null) return
        dfs(root.left);
        res.push(root.val);
        dfs(root.right);
      }
      dfs(root)
      for (let i = 0; i < res.length - 1; i++) {
        if (res[i] >= res[i + 1]) {
          return false
        }
      }
      return true
    }
    console.log(fn([5,1,4,null,null,3,6]))
  </script>
</body>
</html>